--[[ 编码: WMS-56-16 名称: 容器\站台输入变化后 作者:HAN 日期:2025-3-11 级别:固定 (说明本段代码在项目中不太会变化) 函数: AfterCNTRChange 功能: -- 根据输入的容器号,判断在当前工作台是否有该容器号的 组盘明细 ,有显示在【货品明细】页签 -- 如果当前到站台的入库任务中的容器号和扫码输入的容器号不相等报错 更改记录: V2.0 KUN 20250107 需要判断料箱的属性 --]] wms_cntr= require( "wms_container" ) function AfterCNTRChange ( strLuaDEID ) local nRet, strRetInfo -- 获取站台编码 nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "S_STATION_NO","S_CNTR_CODE" ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end local obj_attrs = json.decode( strRetInfo ) local station = lua.Get_StrAttrValue( obj_attrs[1].value ) local cntr_code = lua.Get_StrAttrValue( obj_attrs[2].value ) if ( station == '' ) then return end local action = {} local strCondition if ( cntr_code ~= '' ) then -- 判断料箱属性 -- MDY BY KUN 20250107 local cntr_obj nRet, cntr_obj = wms_cntr.GetInfo( strLuaDEID, cntr_code ) if ( nRet ~= 0 ) then mobox.setInfo( strLuaDEID, "获取容器对象失败! "..cntr_obj ) return end if ( cntr_obj == '' ) then mobox.setInfo( strLuaDEID, "编码 = '"..cntr_code.."'的拣料箱不存在!") return end if ( cntr_obj.source ~= "巨沃" ) then mobox.setInfo( strLuaDEID, "编码 = '"..cntr_code.."'的拣料箱不是巨沃的") return end local act_weight = lua.Get_NumAttrValue( cntr_obj.act_weight ) -- 料箱实际重量 local max_weight = wms_base.Get_nConst(strLuaDEID, "料箱最大载重") local f_acc_weight = act_weight - max_weight -- 判断容器是否处于回库中状态(N_B_STATE = 3/组盘完成,4/回库) strCondition = "S_STATION_NO = '"..station.."' AND ( N_B_STATE = 3 OR N_B_STATE = 4 ) AND S_CNTR_CODE = '"..cntr_code.."'" nRet, data_objs = m3.QueryDataObject(strLuaDEID, "Pre_Alloc_Container", strCondition, "" ) if ( nRet ~= 0 ) then mobox.setInfo( strLuaDEID, "QueryDataObject失败!"..data_objs) return end if ( data_objs == '' ) then mobox.setInfo( strLuaDEID, "料箱号'"..cntr_code.."'没有在站台'"..station.."'") return end local org_cntr = m3.KeyValueAttrsToObjAttr(data_objs[1].attrs) local pac_no = lua.Get_StrAttrValue( org_cntr.S_PAC_NO ) if ( pac_no == '' ) then mobox.setInfo( strLuaDEID, "料箱号'"..cntr_code.."'无法获取当前入库组盘号") return end if (act_weight <= max_weight) then mobox.setInfo( strLuaDEID, "料箱'"..cntr_code.."'没超重,请联系仓管人员" ) else -- 查询并显示料箱货品明细 strCondition = "S_STATION_NO = '"..station.."' AND N_B_STATE = 2 AND S_CNTR_CODE = '"..cntr_code.."' AND S_PAC_NO = '"..pac_no.."'" action = { { action_type = "set_dlg_attr", value = { { attr = "F_ACT_WEIGHT", value = f_acc_weight, enable = false } } }, { action_type = "set_query_condition", value = { condition = strCondition, order = "", page_name = "货品明细" } } } end end strCondition = "S_STATION_NO = '"..station.."' AND N_B_STATE = 0" local action_item = { action_type = "set_query_condition", value = { condition = strCondition, order = "", page_name = "站台超重货品明细" } } table.insert( action, action_item ) lua.Debug( strLuaDEID, debug.getinfo(1), "action --> ", action ) nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo ) end end